{extend name="layout"}
{block name="style"}
<style>

</style>
{/block}
{block name="left_main"}

<ul class="layui-nav layui-nav-tree" style="width:100%;">
    <li class="layui-nav-item {if in_array($action,['index'])}layui-this{/if}"><a href="{:url('spec/index')}">公司管理</a></li>
    <li class="layui-nav-item {if in_array($action,['news'])}layui-this{/if}"><a href="{:url('spec/news')}">信息管理</a></li>
    <li class="layui-nav-item {if in_array($action,['user'])}layui-this{/if}"><a href="{:url('spec/user')}">账密管理</a></li>
    <li class="layui-nav-item {if in_array($action,['files'])}layui-this{/if}"><a href="{:url('spec/files')}">文件管理</a></li>
</ul>
{/block}
{block name="right_main"}
<div class="layui-tab layui-tab-brief" style="margin:0;box-shadow:none;border:0;">
    <ul class="layui-tab-title">
        <li {:request()->action()=='user'?'class="layui-this"':''} onclick="location.href='{:url('spec/user')}'">列表</li>
    </ul>
    <!--    搜索-->
    <div class="layui-tab-content" style="padding:20px;background:#fff;">
        <fieldset class="layui-elem-field">
            <legend>查找</legend>
            <div class="layui-field-box">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                       
                        <div class="layui-inline">
                            <label class="layui-form-label">公司名称</label>
                            <div class="layui-input-inline">
                                <select name="company_id"  lay-filter="" lay-search="true">
                                    <option value="" >请搜索公司名称</option>
                                    {volist name="company" id="vo"}
                                    <option value="{$vo.id}" {:input('company_id')==$vo.id?'selected':''}>{$vo.name}</option>
                                    {/volist}

                                </select>
                            </div>
                        </div>
                        
                         <div class="layui-inline">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <select name="status" lay-filter="">
                                    <option value="">全部</option>
                                    <option value="1" {:input('status')=='1'?'selected':''}>可用</option>
                                    <option value="0" {:input('status')=='0'?'selected':''}>禁用</option>
                                </select>
                            </div>
                        </div>

                    </div>
                      <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">创建时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="min_create_time" value="{:input('min_create_time')?:''}" id="min_create_time" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" name="max_create_time" value="{:input('max_create_time')?:''}" id="max_create_time" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <script>
                            layui.use(['laydate'], function() {
                            var laydate = layui.laydate;
                            laydate.render({
                            elem: '#min_create_time'
                            });
                            laydate.render({
                            elem: '#max_create_time'
                            });
                            });
                        </script>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-inline">
                            <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="search">查找</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
    </div>





    <div class="layui-tab-content" style="padding:20px;">
        {$batheDeleteButton?:''}
        {$addButton?:""}
        <table class="layui-table" lay-data="{skin: 'line',method:'post', url:'{:url('spec/user',input('get.'))}', page:true, id:'table'}" lay-filter="table">
            <thead>
                <tr>
                    <th lay-data="{checkbox:true}"></th>
                    <th lay-data="{field:'id', width:80, sort: true}">ID</th>
                    <th lay-data="{field:'company_id', width:200, sort: true}">公司</th>
                    <th lay-data="{field:'username', width:100}">用户名</th>
                    <th lay-data="{field:'create_time', width:200}">创建时间</th>
                    <th lay-data="{field:'status', width:120, sort: true, templet:'#status'}">发布状态</th>
                    <th lay-data="{width:126,fixed:'right', align:'center', toolbar: '#bar'}">操作</th>
                </tr>
            </thead>
        </table>
        <script type="text/html" id="status">
      {{# if(d.status===1){}}
      <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="status">可用</a>
      {{# }else{}}
      <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="status">禁用</a>
      {{# }}}
    </script>
        <script type="text/html" id="bar">
            <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
            </script>
            <script>
                layui.use(['table', 'jquery'], function(){
                var table = layui.table;
                var $ = layui.jquery;
                table.on('tool(table)', function(obj){
                var data = obj.data;
                if (obj.event === 'edit'){
                layer.open({
                title:'用户编辑',
                        type: 2,
                        maxmin: true,
                        area: ['{:request()->isMobile()?'100 % ':'500px'}', '420px'],
                        id:'editButton',
                        content: '{:url('spec/edituser')}?id=' + data.id,
                        end: function(){
                        location.href = location;
                        }
                });
                }

                if (obj.event === 'del'){
                layer.confirm('风险提示：删除后不可恢复，确定删除？', function(index){
                $.post('{:url('spec/deleteuser')}', {id:data.id}, function(res){
                if (res.code == 1){
                obj.del();
                layer.close(index);
                } else{
                layer.msg(res.msg);
                layer.close(index);
                }
                })
                });
                }

                if (obj.event === 'content'){
                layer.prompt({
                formType: 2
                        , title: '修改'
                        , value: data.content
                }, function(value, index){
                if (value == ''){
                layer.msg('不能为空');
                return false;
                }
                $.post('{:url('news / editNews')}', {id:data.id, field_name:'content', field_value:value}, function(res){
                if (res.code == 1){
                obj.update({content: value});
                layer.close(index);
                } else{
                layer.msg(res.msg);
                }
                });
                });
                }

                });
                });
            </script>


        </div>

    </div>
    {/block}
    {block name="script"}
    <script>
        layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
                , layer = layui.layer
                , laydate = layui.laydate;
        //日期
        laydate.render({
        elem: '#date'
        });
        });
    </script>
    {/block}
